<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/validation.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script>

    var currentchargeCount=0.00;

	 function submitForm(){

	  if(document.getElementById("btn1_12").className=='buttonUnEditMiddle'){
	       return false;
	   }
     setRemarkClass(document.getElementById("credit"));

	  var isTrue=$("addForm").fireEvent("onSubmit");
	  if(isTrue){
	  var url=null;
	  if(document.getElementById("keyword").value==''){
	  url = '${ctx}/customerService_custServiceChargeAction.do?method=saveBill';
	  }else{
	   url = '${ctx}/customerService_custServiceChargeAction.do?method=editBill';
	  }
	  var param=document.addForm.serialize();
	  var myAjax = new Ajax.Request(url, {method: 'post', parameters: param, onComplete: processSaveBill});
	   }
	 }

	 function processSaveBill(result){
			var resultText = result.responseText.strip();
			ajaxSubmitException(resultText);

			if(resultText=='' || resultText==null){
			Alert("保存失败");
			return false;
			}

			document.getElementById("keyword").value=resultText;
           document.getElementById("tempStatuz").innerHTML="新建";
			SuccessAlert("您已保存成功");


	 }

	 function deliveryCharge(){

       setRemarkClass(document.getElementById("credit"));
       var isTrue=$("addForm").fireEvent("onSubmit");
	   if(!isTrue)return false;
       var param=document.addForm.serialize();
        var url = '${ctx}/customerService_custServiceChargeAction.do?method=deliveryCharge';

	  var myAjax = new Ajax.Request(url, {method: 'post', parameters: param, onComplete: processDeliveryCharge});

	 }

	 function processDeliveryCharge(result){
			var resultText = result.responseText;
			try{
			ajaxSubmitException(resultText);
			}catch(ex){
			window.location.href="${ctx}/customerService_custServiceChargeAction.do?method=navigateChargeCalculateMain&dispatchFormId=${dispatchFormId}";
			return false;
			}
			if('true' == resultText){
			   btn_change_UnEdit(1);
			   btn_change_UnEdit(2);
			   document.getElementById("tempStatuz").innerHTML="已传递";

			   document.getElementById("remark").disabled=true;
			   document.getElementById("credit").disabled=true;
			   document.getElementById("mode_one").disabled=true;
			     document.getElementById("mode_two").disabled=true;


			   //001新建;002已传递
			}

	 }

	 function AskConfirmDelivery(){
	   if(document.getElementById("btn1_22").className=='buttonUnEditMiddle'){
	       return false;
	   }
       setRemarkClass(document.getElementById("credit"));
	    var isTrue=$("addForm").fireEvent("onSubmit");
	   if(!isTrue)return false;

	   AskConfirm("您确定要进行费用传递吗？","chargeCalculate","deliveryCharge");
	 }

	 function setHideCredit(credit){
	 currentchargeCount=credit;
	 document.getElementById("debit").value=Number(currentchargeCount);
	 }

	 function setRemarkClass(ojb){
	var temp1= Number(ojb.value);
	var temp2= Number(currentchargeCount);

	   if(temp1==temp2){
	   Validation.changeElmValidate("remark","max-length-100");

	   }else{
	     Validation.changeElmValidate("remark","required max-length-100");
	   }

       if(!isNaN(ojb.value)){
         if((ojb.value.replace(/\s+/g,""))!=''){
          ojb.value=Number(ojb.value);
          }
	   }
	 }

</script>
</head>

<body>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg">
    	<table border="0" cellpadding="0" cellspacing="0">
	      <tr>
	        <td><span class="window_head_intext"><img src="${ctx}/images/ico_Advance.gif" align="absmiddle" />&nbsp;费用核算</span></td>
	      </tr>
    	</table>
    </td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
<tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td  class="content">
    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	      <tr>
	        <td bgcolor="#FFFFFF" border="0" cellspacing="0" cellpadding="0">
	        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#BCBFD2" >
	          <tr>
	            <td>
  <table width="100%" border="0" cellpadding="0" cellspacing="0">

    <tr>
      <td valign="top">
		 <iframe id="chargeItemList"  name="chargeItemList" height="180px" frameborder="0" border="0" src="${ctx}/customerService_dispatchFormAction.do?method=findChargeItemByPage&MenuFlat=false&dispatchFormId=${dispatchFormId}" width="100%" ></iframe>
      </td>
    </tr>
  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
 <form id="addForm" name="addForm" method="post" action="${ctx}/customerService_custServiceChargeAction.do?method=saveBill" class="required-validate">
<input type="hidden" name="dispatchFormId" value="${dispatchFormId}">
<input type="hidden" name="keyword" value="${billVO.keyword}">
<input type="hidden" name="debit" value="${billVO.debit}">
			   <tr>
              <td valign="top" class="aux_intable_td1">实 收：</td>
              <td class="aux_intable_td2"><input name="credit" type="text" class="float-zero-right integer-decimal-rang-18-2" value="${billVO.credit}" size="16" onChange="setRemarkClass(this);"/></td>
              <td valign="top" class="aux_intable_td1">收费方式：</td>
              <td class="aux_intable_require"><input name="mode" id="mode_one" class="validate-one-required" type="radio" value="001" ${billVO.mode=='001'?'checked':''}  />
                现场收费                   &nbsp;　&nbsp;　&nbsp;&nbsp;
                <input type="radio" name="mode" id="mode_two" class="validate-one-required" value="002" ${billVO.mode=='002'?'checked':''}/>
                月末结算</td>
            </tr>
            <tr>
              <td valign="top" class="aux_intable_td1">备 注：</td>
              <td class="aux_intable_td2">
                <textarea name="remark" cols="20" rows="2" class="max-length-100">${billVO.remark}</textarea></td>
              <td class="aux_intable_td1">状 态：</td>
              <td class="aux_intable_td2"><span id="tempStatuz">
              <c:if test="${billVO.statuz=='001'}">新建</c:if>
			  <c:if test="${billVO.statuz=='002'}">传递</c:if>
              </span>
              <input type="hidden" name="statuz" value="${billVO.statuz}">
              </td>
            </tr>
</form>
        </table>

</td>
     </tr>
        </table></td>
    </tr>
  </table>

</td>
  </tr>
  <tr>
    <td colspan="2" class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>

        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onClick="AskConfirmDelivery();" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onBlur="btn_change(2)"><img id="img_btn1_22" src="${ctx}/images/ico_zxsf_sq.gif" alt="" width="14" height="14" border="0" align="absbottom" />费用传递</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
		<td class="btn_between_space"></td>
		<td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_11"></td>
              <td class="buttonOffMiddle" id="btn1_12" onClick="submitForm();" onMouseOver="btn_change_over(1)" onMouseOut="btn_change_out(1)" onBlur="btn_change(1)"><img id="img_btn1_12" src="${ctx}/images/ico_yhhk_rp.gif" alt="" width="16" height="16" border="0" align="absbottom" /> 保 存</td>
              <td class="buttonOffRight" id="btn1_13"></td>
            </tr>
        </table></td>

          <td class="btn_between_space"></td>
          <td>
          	<table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td class="buttonOffLeft" id="btn1_31"></td>
                <td class="buttonOffMiddle"
                	id="btn1_32"
                	onClick="windowClose();"
                	onMouseOver="btn_change_over(3)"
                	onMouseOut="btn_change_out(3)"
                	onBlur="btn_change(3)">
                	<img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 关 闭</td>
                <td class="buttonOffRight" id="btn1_33"></td>
              </tr>
          </table></td>
        </tr>
          </table>
      <p>&nbsp;</p></td>
  </tr>
</table>
</div>
</body>
<script type="text/javascript">
  if(${billVO.statuz=='002'}){
  btn_change_UnEdit(1);
   btn_change_UnEdit(2);
   document.getElementById("remark").disabled=true;
	document.getElementById("credit").disabled=true;
	document.getElementById("mode_one").disabled=true;
	 document.getElementById("mode_two").disabled=true;
  }


</script>
</html>

